import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/constans/dict_data_info.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/data/entities/application/get_dict_all_entity.dart';

class SecurityResponsibilityController extends GetxController with GetSingleTickerProviderStateMixin {
  late TabController tabController; //TabController 变量

  /// 搜索使用key
  final GlobalKey<CustomEasyRefreshListState> globalKey1 = GlobalKey();

  /// 搜索使用key
  final GlobalKey<CustomEasyRefreshListState> globalKey2 = GlobalKey();

  /// 搜索使用key
  final GlobalKey<CustomEasyRefreshListState> globalKey3 = GlobalKey();

  /// 任务管理_任务类型_来源于字典
  /// key 1:主要负责人 2:技术负责人 3:操作负责人
  Map<int, String> workTypeDicIdMap = {};

  @override
  void onInit() {
    super.onInit();
    //初始化tabController
    tabController = TabController(vsync: this, length: 3);
    //获取作业人类型
    getWorkTypeDic();
  }

  /// 获取作业人类型
  Future<void> getWorkTypeDic() async {
    final List<GetDictAllEntity> dictList = await DictDataInfo.getDictionaryDataByTree(dictionaryType: 'hidden_danger_investigation_task_work_type');
    if (dictList.isNotEmpty) {
      for (var item in dictList) {
        switch (item.dictionaryKeyValues) {
          // 1:主要负责人
          case '1':
            workTypeDicIdMap[1] = item.id!;
            break;
          // 2:技术负责人
          case '2':
            workTypeDicIdMap[2] = item.id!;
            break;
          // 3:操作负责人
          case '3':
            workTypeDicIdMap[3] = item.id!;
            break;
        }
      }
      update();
    }
  }
}
